package com.ly.lytestbootkotlin.service.impl

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
import com.ly.lytestbootkotlin.domain.Result
import com.ly.lytestbootkotlin.domain.po.User
import com.ly.lytestbootkotlin.mapper.UserMapper
import com.ly.lytestbootkotlin.service.IUserService
import org.springframework.stereotype.Service

@Service
class UserServiceImpl : ServiceImpl<UserMapper,User>(),IUserService {

    /**
     * 测试：获取所有表中数据
     */
    override fun getUsers(): Result {
        val list = this.lambdaQuery().list()
        return Result.ok(list)
    }

    override fun getUser(id: Long): Result {
        if (id == 0L){
            return Result.fail("id不能为空")
        }
        println(id)
        val one = this.query().eq("id", id).one()
//        val one = this.lambdaQuery().eq(User::id,id).one()
        return Result.ok(one)
    }
}